package com.tangcl.module_commom.network.interceptor

import okhttp3.Interceptor
import okhttp3.Response


/**
 * Created by TCL on 2021/7/7
 *
 * description:添加参数的拦截器
 * 如添加请求头
 */
class AddQueryParameterInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val original = chain.request()

        //方式一
        original.newBuilder()
//            .header("", "")//相同参数--覆盖
//            .addHeader("", "")//相同参数--不覆盖
            .build()
        return chain.proceed(original)

        //方式二
//        val originalHttpUrl = original.url
//        originalHttpUrl.newBuilder()
//            .addQueryParameter("","")
//            .build()
//        val request = original.newBuilder().url(originalHttpUrl).build()
//        return chain.proceed(request)
    }
}